package com.zmytest.annotation.exceptionhandler;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created on 2019/1/2.
 *
 * @author zhangmingyu
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(MyException.class)
    @ResponseBody
    public ResponseDto customHandler(MyException e){
        e.printStackTrace();
        return ResponseDto.fail(e.getMsg());
    }
}
